<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>成功案例管理</title>
<style type="text/css">
form fieldset{
	display: none;
}
form fieldset.defaultForm{
	display: block;
}
</style>
<link rel="stylesheet" href="${ctx }/extends/uploadify/uploadify.css" type="text/css" media="screen" />
<script type="text/javascript" src="${ctx}/extends/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
// The instanceReady event is fired, when an instance of CKEditor has finished
// its initialization.
CKEDITOR.on( 'instanceReady', function( ev ) {

});
</script>
<%@ include file="/common/header.jsp" %>
    <div class="content-box">
      <!-- Start Content Box -->
      <div class="content-box-header">
        <h3>添加成功案例</h3>
        <div class="clear"></div>
      </div>
      <!-- End .content-box-header -->
      <div class="content-box-content">
          <form action="${ctx }/successfulCase/save.do" method="post">
	          <c:set var="successfulCaseNo">
		          <c:choose>
		          	<c:when test="${empty zh.successfulCaseNo}">${en.successfulCaseNo}</c:when>
		          	<c:when test="${empty en.successfulCaseNo }">${zh.successfulCaseNo}</c:when>
		          	<c:otherwise>${en.successfulCaseNo}</c:otherwise>
		          </c:choose>
	          </c:set>  
            <fieldset class="zh-successfulCase <c:if test="${defaultForm eq 'zh'}">defaultForm</c:if>" >             
            <div class="block-layout">          
              <label>编号: ${successfulCaseNo }</label>
              <input type="hidden" name="zh.successfulCaseId"  value="${zh.successfulCaseId }"/>     
              <input type="hidden" name="zh.successfulCaseNo"  value="${successfulCaseNo }"/>    
              <input type="hidden" name="zh.successfulCaseStatus"  value="${zh.successfulCaseStatus }"/>
              <input type="hidden" name="zh.isTop"  value="${zh.isTop }"/>                      
            <p>
              <label for="zh_languageId" >語言：</label>
              <select name="zh.languageId"  id="zh_languageId" class="bigger-input">
              	<c:forEach items="${language }"  var="l">
              		<option value="${l.languageId }"  data-key="${l.languageKey }"  <c:if test="${l.languageKey eq 'zh'}">selected='selected'</c:if>>${l.languageName }</option>
              	</c:forEach>
              </select>
            </p>
            <p>
              <label>型號：</label>
              <input type="text" class="text-input bigger-input" name="zh.successfulCaseModel"  value="${zh.successfulCaseModel}"/>
            </p>            
            <p>
              <label>成功案例：</label>
              <input type="text"  class="text-input bigger-input" name="zh.successfulCaseName"  value="${zh.successfulCaseName}"/>
            </p>
            </div>
            <div class="block-layout">
            <label>&nbsp;</label>
            <p>
              <label for="zh_successfulCaseCategoryId" >類別：</label>
              <select name="zh.successfulCaseCategoryId"  id="zh_successfulCaseCategoryId" class="bigger-input">
              	<option value="">請選擇..</option>
              	<c:forEach items="${zhCategory }"  var="c">
	              	<option value="${c.productCategoryId }"  <c:if test="${c.productCategoryId eq zh.successfulCaseCategoryId}">selected='selected'</c:if>>${c.categoryName }</option>
              	</c:forEach>
              </select>
            </p>
            <p>
              <label>日期：</label>
              <fmt:formatDate value="${ zh.successfulCaseDate}" var="zhdate"  type="date" pattern="yyyy-MM-dd hh:mm"/>
              <input type="text"  class="text-input bigger-input datepicker" id="zh_successfulCaseDate" name="zh.successfulCaseDate"  value="${zhdate}"/>
           </p>
            <p>
              <label>圖片：</label>
              <input type="hidden"  class="text-input bigger-input"  name="zh.uploadFileSetInfoId"  value="${zh.uploadFileSetInfoId}"/>
              <input type="file"  id="zh_uploadFileSetInfoId" />
              <c:if test="${!empty zh_uploadFileInfo }">
              <div id="zh_uploadFileSetInfoId_history"  class="uploadify-queue">
					<c:forEach items="${zh_uploadFileInfo}" var="file" varStatus="index">
						<div id="SWFUpload_${file.uploadFileInfoId}_${index.index}" data-uploadfileid="${file.uploadFileInfoId}" class="uploadify-queue-item">
							 <div class="cancel">
									<a href="javascript:$('#zh_uploadFileSetInfoId').uploadify('cancel','SWFUpload_${file.uploadFileInfoId}_${index.index}')">X</a>
							</div>
							<span class="fileName">
								<a href="${ctx }/successfulCase/downloadFile.do?uploadFileInfoById=${file.uploadFileInfoId}">${fn:escapeXml(file.fileName)}</a>
							</span>
						</div>
					</c:forEach>
				</div>
				</c:if>
				<input type="button" value="设置主图" class="setMainImage">
            </p>
            </div>
             <div class="clear"></div>
            <p>
              <label>詳細介紹：</label>
              <textarea class="text-input textarea"  name="zh.successfulCaseContent" cols="79" rows="15" >${zh.successfulCaseContent }</textarea>
              <script type="text/javascript">
				// Replace the <textarea id="textarea_content"> with an CKEditor instance.
				CKEDITOR.replace( 'zh.successfulCaseContent',{
					language: "zh"
				});			
			  </script>           	
            </p>
            </fieldset>
            <div class="clear"></div>
            <!-- End .clear -->
             <fieldset class="en-successfulCase <c:if test="${defaultForm eq 'en'}">defaultForm</c:if>">           
            <div class="block-layout">
              <label>No.: ${successfulCaseNo }</label>
              <input type="hidden" name="en.successfulCaseId"  value="${en.successfulCaseId }"/>     
              <input type="hidden" name="en.successfulCaseNo"  value="${successfulCaseNo }"/>
              <input type="hidden" name="en.successfulCaseStatus"  value="${en.successfulCaseStatus }"/>
              <input type="hidden" name="en.isTop"  value="${en.isTop }"/>
             <p>
              <label for="en_languageId" >Language：</label>
              <select name="en.languageId"  id="en_languageId" class="bigger-input">
              	<c:forEach items="${language }"  var="l">
              		<option value="${l.languageId }"   data-key="${l.languageKey }" <c:if test="${l.languageKey eq 'en'}">selected='selected'</c:if>>${l.languageName }</option>
              	</c:forEach>
              </select>
            </p>             
           <p>
              <label>Model：</label>
              <input type="text"  class="text-input bigger-input" name="en.successfulCaseModel"  value="${en.successfulCaseModel}"/>
            </p>
            <p>
              <label>Name：</label>
              <input type="text"  class="text-input bigger-input" name="en.successfulCaseName"  value="${en.successfulCaseName }"/>
            </p>           
            </div>
            <div class="block-layout">
            <label>&nbsp;</label>
			<p>
              <label for="en_successfulCaseCategoryId" >Category：</label>
              <select name="en.successfulCaseCategoryId"  id="en_successfulCaseCategoryId" class="bigger-input">
              	<option  value="">Please Select...</option>
              	<c:forEach items="${enCategory }"  var="c">
	              	<option value="${c.productCategoryId }" <c:if test="${c.productCategoryId eq en.successfulCaseCategoryId}">selected='selected'</c:if>>${c.categoryName }</option>
              	</c:forEach>
              </select>
            </p>
            <p>
              <label>Date：</label>
              <fmt:formatDate value="${ en.successfulCaseDate}" var="endate"  type="date" pattern="yyyy-MM-dd hh:mm"/>
              <input type="text"  class="text-input bigger-input datepicker"  id="en_successfulCaseDate" name="en.successfulCaseDate"  value="${endate}"/>
           </p>
           <p>
              <label>Picture：</label>
              <input type="hidden"  class="text-input bigger-input" name="en.uploadFileSetInfoId"  value="${en.uploadFileSetInfoId}"/>
              <input type="file"  id="en_uploadFileSetInfoId"/>
              <c:if test="${!empty en_uploadFileInfo }">
              <div id="en_uploadFileSetInfoId_history"  class="uploadify-queue">
					<c:forEach items="${en_uploadFileInfo}" var="file" varStatus="index">
						<div id="SWFUpload_${file.uploadFileInfoId}_${index.index}" data-uploadfileid="${file.uploadFileInfoId}" class="uploadify-queue-item">
							 <div class="cancel">
									<a href="javascript:$('#en_uploadFileSetInfoId').uploadify('cancel','SWFUpload_${file.uploadFileInfoId}_${index.index}')">X</a>
							</div>
							<span class="fileName">
								<a href="${ctx }/successfulCase/downloadFile.do?uploadFileInfoById=${file.uploadFileInfoId}">${fn:escapeXml(file.fileName)}</a>
							</span>
						</div>
					</c:forEach>
				</div>
				</c:if>
				<input type="button" value="Set Main" class="setMainImage">
            </p>
            </div>
             <div class="clear"></div>
            <p>
              <label>Detail：</label>
              <textarea class="text-input textarea"  name="en.successfulCaseContent" cols="79" rows="15" >${en.successfulCaseContent }</textarea>
              <script type="text/javascript">
				// Replace the <textarea id="textarea_content"> with an CKEditor instance.
				CKEDITOR.replace( 'en.successfulCaseContent',{language: "en"});
			  </script>           	
            </p>
            </fieldset>
            <p>
              <input class="button" type="submit" value="Submit" />
            </p>
            <div class="clear"></div>
          </form>
      </div>
      <div id="setMainFile" style="display:none">
      
      </div>
      <!-- End .content-box-content -->
    </div>
    <!-- End .content-box -->   
    <div class="clear"></div>
 <%@ include file="/common/footer.jsp" %>
  <script type="text/javascript" src="${ctx}/extends/uploadify/jquery.uploadify.js?_=${radom}"></script>
 <script type="text/javascript" src="${ctx}/extends/jquery.json-2.3.js?_=${radom}"></script>
 <script type="text/javascript" src="${ctx}/extends/jquery-ui-timepicker-addon.js?_=${radom}"></script>
 <script type="text/javascript" src="${ctx}/js/successfulCaseAdd.js?_=${radom}"></script>
 <script type="text/javascript">
 $(function(){
 	 $("#main-nav a[data-menu='successfulCase']").addClass("current").click();
	 $("#main-nav a[data-menu='successfulCaseList']").addClass("current");
 })
 </script>